<?php

namespace app\modules\pay\provider;

use app\modules\pay\utils\SignUtil;

class RefundProvider {

    //退款
    public static function getRefundCode($order_no,$refund_no,$refund_amount,$pay_channel,$config){
        $params = [
            'mch_no'=>$config['mch_no'],
            'sign_type'=>'MD5',
            'nonce_str'=>\Yii::$app->getSecurity()->generateRandomString(),
            'out_trade_no'=>$order_no,
            'refund_trade_no'=>$refund_no,
            'refund_amount'=>$refund_amount,
            'notify_url'=>\Yii::$app->params['payment']['domain'] . "/pay/notify/refund-notify",
        ];
        $params['sign'] = SignUtil::sign($params,$config['sign_key']);
        $params['service'] = "pay.mobile.refund";
        $params['pay_channel'] = $pay_channel - 1;
        return $params;
    }
}